package com.kk.tx.service;

import com.kk.tx.scan.AppConfig;
import com.kk.tx.scan.WebConfig;
import com.kk.tx.service.controller.TransController;
import org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor;
import org.springframework.context.annotation.AnnotationConfigUtils;
import org.springframework.context.support.GenericApplicationContext;

public class Testtx5 {
    public static void main(String[] args) {
        // 父容器，扫整个 com.kk.tx 下个包
        GenericApplicationContext parent = new GenericApplicationContext ( );
        AnnotationConfigUtils.registerAnnotationConfigProcessors (parent.getDefaultListableBeanFactory ());
        ConfigurationPropertiesBindingPostProcessor.register (parent.getDefaultListableBeanFactory ());
        parent.registerBean (AppConfig.class);
        parent.refresh ();
        // 子容器,扫 tx 包下具体的 com.kk.tx.service 包
        GenericApplicationContext child = new GenericApplicationContext ( );
        AnnotationConfigUtils.registerAnnotationConfigProcessors (child.getDefaultListableBeanFactory ());
        child.setParent (parent);
        child.registerBean (WebConfig.class);
        child.refresh ();

        TransController bean = child.getBean (TransController.class);
        bean.test5 (1,2,10);

    }
}
